function [chi] = SolZenith(lat, LT, sinSun, cosSun)
%
% Solar Zenith Angle
%
%DESCRIPTION:
%This function computes the Solar Zenith Angle (chi).
%
%PROTOTYPE:
% [chi] = SolZenith(lat, LT, sinSun, cosSun)
%
%--------------------------------------------------------------------------
% INPUTS:
%   lat        [1x1]       Latitude                  [deg]
%   LT         [1x1]       Local Time                [hours]
%   sinSun     [1x1]       Solar Decl. Sine          [-]
%   cosSun     [1x1]       Solar Decl. Cosine        [-]
%--------------------------------------------------------------------------
% OUTPUTS:
%   chi        [1x1]       Solar Zenith Angle        [deg]
%--------------------------------------------------------------------------
%
%NOTES:
% (none)
%
%CALLED FUNCTIONS:
% (none)
%
%UPDATES:
% (none)
%
%REFERENCES:
% [1] "Ionospheric Correction Algorithm for Galileo Single-Frequency Users"
%      - European GNSS (Galileo) Open Service
%
%AUTHOR(s):
%Luigi De Maria, Matteo D'Addazio, 2022
%

%% Main Code

%Constants
DR = pi/180;                %Conversion Factor: deg->rad
RD = 180/pi;                %Conversion Factor: rad->deg

%Solar Zenith Angle [deg]
cosChi = sin(lat*DR)*sinSun + cos(lat*DR)*cosSun*cos(pi/12*(12 - LT));
chi = RD * atan2(sqrt(1-cosChi^2),cosChi);


end